#!/bin/bash

echo "=== 开始启动高德地图MCP服务 ==="

# 设置高德地图API Key - 使用Web端密钥
export AMAP_MAPS_API_KEY=5167e1072a5f26767abb39b6f579c07c
echo "设置API Key: $AMAP_MAPS_API_KEY"

# 检查环境变量是否成功设置
echo "验证API Key设置: $AMAP_MAPS_API_KEY"
if [ -z "$AMAP_MAPS_API_KEY" ]; then
  echo "错误: AMAP_MAPS_API_KEY环境变量未设置"
  exit 1
fi

# 显示启动信息
echo "API Key长度: ${#AMAP_MAPS_API_KEY} 字符"
echo "准备启动MCP服务..."

# 使用npx启动MCP服务
echo "执行命令: npx -y @amap/amap-maps-mcp-server"
npx -y @amap/amap-maps-mcp-server

# 捕获退出状态
EXIT_CODE=$?

# 根据退出状态输出信息
if [ $EXIT_CODE -ne 0 ]; then
  echo "错误: MCP服务启动失败，退出代码: $EXIT_CODE"
  exit $EXIT_CODE
else
  echo "MCP服务已正常终止"
fi

